<?php 
/**
 * eBay Label Printing Program System backoffice Menu Database Table Class 
 * this is a Db Table Class , It stores Backoffice menu links for the actions
 * @package  eBayLabelPrinter
 * @category Models/DbTable
 * @author   Norman Dong <norman.dong@hotmail.com>
 * @version  Initial
 * @copyright LeadCasket.com
 * @link     www.leadcasket.com
 * @license  Commercial
 */
 class Model_DbTable_System_Backofficemenu extends Zend_Db_Table_Abstract 
{
	/**
	 * @var string Class Table Name
	 */
	const TOP_LEVEL_MENU = 0;
	protected $_name = 'system_backoffice_menu'; 
	/**
	 * Get Seller Group By ID 
	 * Not decide what to do Yet
	 * @param int $idSeller  The Seller ID
	 * @return array  Not decide what to return 
	 */	
	public function getBackofficeMenu($menuID){
		$row = $this->fetchRow('`id_backoffice_menu`='.(int)$menuID);
		if(!$row){
			return false;
		}
		return $row->toArray();
	}
	public function addBackofficeMenu($parentMenuID,$menuOrder,$menuName,$menuLink,$menuLevel,$menuIcon){
		
		$data = array(
				'id_parent_backoffice_menu' =>$parentMenuID,
				'order_backoffice_menu' =>$menuOrder,
				'name_backoffice_menu' =>$menuName,
				'link_backoffice_menu' =>$menuLink,
				'level_backoffice_menu' =>$menuLevel,
				'icon_backoffice_menu' =>$menuIcon,
				);
		$this->insert($data);
	}
	public function updateBackofficeMenu($menuID,$parentMenuID,$menuOrder,$menuName,$menuLink,$menuLevel,$menuIcon){
		
		$data = array(
				'id_parent_backoffice_menu' =>$parentMenuID,
				'order_backoffice_menu' =>$menuOrder,
				'name_backoffice_menu' =>$menuName,
				'link_backoffice_menu' =>$menuLink,
				'level_backoffice_menu' =>$menuLevel,
				'icon_backoffice_menu' =>$menuIcon,
		);
		$this->update($data,'id_backoffice_menu='.$menuID);
	}
	public function deleteBackofficeMenu($menuID){
		$this->delete('id_backoffice_menu =' . $menuID);
	}
	
	public function listTopLevelMenu(){
		
		return self::listSubMenu(self::TOP_LEVEL_MENU);
	}
	public function listSubMenu($parentMenuID){
		$rows = $this->fetchAll('id_parent_backoffice_menu = '.$parentMenuID);
		return $rows->toArray();
		
	}
	public function listMenu(){
		$rows = $this->fetchAll('1');
		return $rows->toArray();
				
		
	}		
}
?>